package at.pp.match3.activity.listener;

import org.anddev.andengine.entity.IEntity;
import org.anddev.andengine.entity.modifier.IEntityModifier.IEntityModifierListener;
import org.anddev.andengine.entity.modifier.MoveModifier;
import org.anddev.andengine.util.modifier.IModifier;

import at.pp.match3.activity.StartActivity;
import at.pp.match3.util.LOG;

public final class IEntityModifierListenerImplementation implements
        IEntityModifierListener {
    /**
	 * 
	 */
    private final StartActivity startActivity;

    /**
     * @param startActivity
     */
    public IEntityModifierListenerImplementation(StartActivity startActivity) {
        this.startActivity = startActivity;
    }

    @Override
    public void onModifierFinished(IModifier<IEntity> pModifier, IEntity pItem) {
        LOG.log("*********** motion finished ***********");
        this.startActivity.ball.clearUpdateHandlers();
        this.startActivity.ball.registerEntityModifier(new MoveModifier(3,
                this.startActivity.ball.getX(), this.startActivity.random
                        .nextInt(StartActivity.CAMERA_WIDTH),
                this.startActivity.ball.getY(), this.startActivity.random
                        .nextInt(StartActivity.CAMERA_HEIGHT),
                new IEntityModifierListenerImplementation(this.startActivity)));
    }
}
